package com.bgs.engineering.security.jwt;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Base64;

/**
 * @ClassName JWTConfig
 * @Description jwt 配置信息类
 * @Author zcy
 * @Date 2023/3/27 15:59
 **/
@Configuration
@ConfigurationProperties(prefix = "jwt")
public class JWTConfig {

    /**
     * 密匙KEY
     */

    public static String secretKey;

    public  void setSecretKey(String secretKey) {
        JWTConfig.secretKey = Base64.getEncoder().encodeToString(secretKey.getBytes());
    }

    /**
     * Header 请求投中token key的定义
     */

    public static String tokenHeader;
    /**
     * 密匙KEY
     */

    public static String tokenPrefix;
    /**
     * 过期时间
     */

    public static long expiration;

    public  void setTokenHeader(String tokenHeader) {
        JWTConfig.tokenHeader = tokenHeader;
    }

    public  void setTokenPrefix(String tokenPrefix) {
        JWTConfig.tokenPrefix = tokenPrefix;
    }

    public  void setExpiration(long expiration) {
        JWTConfig.expiration = expiration;
    }
}
